package com.lcq.springbootcreate;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
//在基本的contraller中有restful的能力
@RestController
@RequestMapping("/prefix")
public class paraContraller {
//    正常访问
    @GetMapping({"/firstrequest"})
    public String firstRequest(){
        return "第一个spring boot";
    }
//    从请求url中获取参数
    @GetMapping({"/requestParam"})
    public String requestParam(@RequestParam Integer num){
        return "para from request"+num;
    }
//    多个url映射到同一个方法
    @GetMapping({"mul1","mul2"})
    public String mulURL(){
        return "multiply url";
    }

//    必须传输参数的方法 如果没有传输参数
    @GetMapping({"/required"})
    public String required(@RequestParam(required = false,defaultValue = "99") Integer num){
        return "para from request"+num;
    }
}
